package com.iflytek.jcy.supervise.clue.common.exception;

import java.util.HashMap;
import java.util.Map;

import com.iflytek.jcy.supervise.clue.common.enums.ResultEnum;
import com.iflytek.jcy.supervise.clue.common.enums.ResultType;


/**
 * 基础异常
 *
 * @author <a href=mailto:ktyi@iflytek.com>伊开堂</a>
 * @date 2019-08-06 11:38
 */
public class BaseException extends RuntimeException {
    private static final long serialVersionUID = 8832650084951672891L;

    private final ResultType resultType;

    private final Map<String, Object> data = new HashMap<>();

    public BaseException() {
        this.resultType = ResultEnum.FAILED;
    }

    public BaseException(ResultType resultType) {
        this.resultType = resultType;
    }

    public BaseException(ResultType resultType, String message) {
        super(message);
        this.resultType = resultType;
    }

    public BaseException(ResultType resultType, Throwable cause) {
        super(cause);
        this.resultType = resultType;
    }

    public BaseException(ResultType resultType, String message, Throwable cause) {
        super(message, cause);
        this.resultType = resultType;
    }

    public Map<String, Object> addData(String key, Object value) {
        data.put(key, value);
        return this.data;
    }

    public Map<String, Object> getData() {
        return this.data;
    }

    public ResultType getResultType() {
        return resultType;
    }
}
